package com.qcby.controller;

import com.qcby.entity.User;
import com.qcby.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("goAdd")
    public String goAdd(){
        return "user/add";
    }
    @RequestMapping("add")
    public String add(User user){
        userService.add(user);
        return "user/add";
    }
    @RequestMapping("find")
    public String find(User user, Model model){
        List<User> list = userService.findList(user);
        model.addAttribute("users",list);

        return "user/list";
    }
}
